<?php
	function checkActivation($email, $key)
	{
		$q = mysql_query("SELECT * FROM account WHERE email='".$email."' AND activationkey='".$key."'");
		if(mysql_num_rows($q) == 0)
		{
			echo '<font color="red">- Invalid key, please check your link.</font>';
		}
		else
		{
			mysql_query("UPDATE account SET grade='1' WHERE email='".$email."'");

			$q = mysql_query("SELECT id, username FROM account WHERE email='".$email."'");
			$f = mysql_fetch_array($q);
			$_SESSION['uid'] = $f['id'];
			$_SESSION['user'] = $f['username'];

			$q = mysql_query("SELECT id, name FROM characters WHERE aid='".$f['id']."'");
			$f = mysql_fetch_array($q);
			$_SESSION['cid'] = $f['id'];
			$_SESSION['char'] = $f['name'];

			echo '<font color="green">- Account activated!<br>
			Click <a href="?page=help">here</a> to login!';
		}

	}
?>